local Decor = {x = 0, y = 0, q}

local quads = {}
local oldX = 0

for y=0, 171, 171 do
    for x=0, 152*3,152 do
        local quad = lg.newQuad(x,y, 152,171, bkgImage)
        table.insert(quads,quad)
    end
end

local function newPosition()
    local newX = love.math.random(-25, lg.getWidth() - 152)
    if newX > oldX - 100 and newX < oldX + 100 then
        newX = newPosition()
    end
    oldX = newX
    return newX
end

function Decor:new()
    local decor = {} or Decor
    decor.x = newPosition()
    decor.y = -171

    local quadID = love.math.random(1,#quads)
    decor.q = quads[quadID]
    
    setmetatable(decor,self)
    self.__index = self
    table.insert(bkgDecor, decor)
    return decor
end

function Decor.update(self,dt)
    if self.y < lg.getHeight() then
        self.y = self.y + 5 * dt * speedMultiplier
    else
        local i = table.find(bkgDecor, self)
        table.remove(bkgDecor, i)
    end
end

 return Decor
